package co.fitstart.weapp.api.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.demo2do.core.persistence.GenericDaoSupport;
import com.demo2do.core.persistence.annotation.Dao;

import co.fitstart.entity.principal.Principal;
import co.fitstart.weapp.api.dao.CoachDao;
import co.fitstart.weapp.api.service.CoachService;

/**
 * 
 * @author haiyan_xiao
 *
 */
@Service("coachService")
public class CoachServiceImpl implements CoachService {

    @Dao
    private CoachDao coachDao;

    @Autowired
    private GenericDaoSupport genericDaoSupport;

    /*
     * (non-Javadoc)
     * @see co.fitstart.weapp.api.service.CoachService#load(java.lang.Long)
     */
    public Principal load(Long coachId) {
        Principal coach = genericDaoSupport.load(Principal.class, coachId);
        return coach != null && !coach.isDisabled() ? coach : null;
    }

    /*
     * (non-Javadoc)
     * @see co.fitstart.weapp.api.service.CoachService#load(java.lang.String)
     */
    public Principal load(String mobile) {
        return coachDao.load(mobile);
    }

	@Override
	public int count(Principal coach, Boolean read) {
		read=false;
		return coachDao.count(coach, read);
	}

}
